#include "printtask.h"
#include <QThread>
#include <iostream>
#include <QMutex>
#include <QEventLoop>
#include <QDebug>
#include "mydialog.h"
#include <unistd.h>
using std::cout;
using std::endl;

PrintTask::PrintTask(QObject *parent)
    : QObject(parent)
{
}

PrintTask::~PrintTask()
{
    QMutex m;
    cout << "~PrintTask" << endl;
}

//线程真正执行的内容
void PrintTask::run()
{
    QMutex m;
    cout << "PrintTask run 被调用，调用线程ID为：" << QThread::currentThread() << " type is " << typeid(QThread::currentThread()).name() << endl;

//    MyDialog d;
//    d.exec();
    qDebug() << "in PrintTask run, will emit dialog_show, current thread id is " << QThread::currentThread() << " to int is " << (void*)(QThread::currentThread());
    emit dialog_show((void*)(QThread::currentThread()));

//    QEventLoop e;
//    e.exec();

//    QThread::sleep(5);
}

